const _ = require('lodash');

function eContractHaveProcurement(data) {
  const formDetail = data.formDetail;
  const totalContractAmount = formDetail.totalContractAmount;
  if (totalContractAmount >= 100000) return true;
  return false;
}

function eContractHaveLegal(data) {
  const formDetail = data.formDetail;
  const createPo = formDetail.createPo;
  const isMeeting = formDetail.isMeeting;
  const totalContractAmount = formDetail.totalContractAmount;
  if ((createPo && isMeeting && totalContractAmount >= 10000) || (createPo && !isMeeting && totalContractAmount >= 20000)) return true;
  return false;
}

function eContractHaveEC(data) {
  const formDetail = data.formDetail;
  if (formDetail.acdd) return true;
  return false;
}

function manpowerRequisitionHaveBusiness(data) {
  const formDetail = data.formDetail;
  if (!_.isEmpty(formDetail.business) && !_.isEmpty(formDetail.approvalStep2Approver)) return true;
  return false;
}

module.exports = {
  eContractHaveProcurement,
  eContractHaveLegal,
  eContractHaveEC,
  manpowerRequisitionHaveBusiness,
};
